<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
import { getToken, setToken, removeToken } from '@/utils/auth'
export default  {
  name:  'App',
  created(){

      let HRESs = window.location.href
      let index = HRESs.lastIndexOf("Authorization=")
    if(HRESs.indexOf("Authorization") != -1){
      let RouterUrl = location.pathname
      let AdminToken = HRESs.substring(index+14,HRESs.length);
        setToken(AdminToken)
        this.$store.dispatch("IsInsideFunction", false)
        // setTimeout(()=>{
        this.$router.push(RouterUrl)
        // },500)
        // setTimeout(() => {
        //   this.getConfigure()
        // }, 1000);
      }
  },
  computed:{
    routerUrl(){
        return this.$route.fullPath
    }
  },
  watch:{
    routerUrl(){
      // http://localhost/resources/apply
      // eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImM5MGFmM2IwLTUyNDMtNGUwMy05ZjMyLTE0MDNkMTQwY2E3YSJ9.X4-7gG3zYesUQEpTC1o3vj4jF4i8L9JYc1PUnqcLnHgScPNOBU7UBLmv7jBfUgyPq2T8ffhznbJr6eRioBXcHA
      if(this.$route.query.token){
        return
        console.log('监听切换')
        let index = this.$route.query.token.lastIndexOf("=")
        let AdminToken = this.$route.query.token.substring(index+1,this.$route.query.token.length);
        this.$store.dispatch("IsInsideFunction", false)
        setToken(AdminToken)
        setTimeout(()=>{
          this.$router.push(this.$route.path)
        },10)
      }
    }
  },
  methods:{
    getConfigure() {
      let configure = {
        available_domain: [], //可用域
        cloud_service_provider: [], //服务商
        storage_type: [], //系统盘类型
        codeList: [], //云服务器规格列表
        czxtList: [], //操作系统列表
        ccList: [], //数据盘类型
        fwcpList: [], //服务型磁盘类型
        wlfwqList: [], //高性能服务器资源类型
        sjkList: [], //数据库类型
        yyaqList: [], //安全产品
        dept: [], //部门列表树结构
      }
      //部门列表树结构
      // treeselect({}).then((response) => {
      //   configure.dept = response.data;
      // });
      //可用域
      getDicts("available_domain").then((response) => {
        configure.available_domain = response.data;
      });
      //服务商
      getDicts("cloud_service_provider").then((response) => {
        configure.cloud_service_provider = response.data;
      });
      //盘类型
      serviceByClazz({
        code: "cc"
      }).then((response) => {
        response.data.forEach((item) => {
          if (["FCcc(tykcc)2", "FCcc_ssd", "spycc2"].indexOf(item.code) < 0) {
            configure.storage_type.push(item);
          }
          if (["spycc2"].indexOf(item.code) < 0) {
            configure.ccList.push(item);
          }
          if (["fbscc_wjcc2", "FCcc(tykcc)2", "FCcc_ssd"].indexOf(item.code) < 0) {
            configure.fwcpList.push(item);
          }
        });
      });
      //操作系统
      serviceByClazz({
        code: "czxt"
      }).then((response) => {
        configure.czxtList = response.data;
      });
      //云服务器规格列表
      listByCode("spec_ecs").then((response) => {
        configure.codeList = response.data;
      });
      //高性能服务器资源类型列表
      serviceByClazz({
        code: "wlfwq"
      }).then((response) => {
        configure.wlfwqList = response.data;
      });
      //数据库类型列表
      serviceByClazz({
        code: "sjk"
      }).then((response) => {
        configure.sjkList = response.data;
      });
      //安全产品列表
      serviceByClazz({
        code: "yyaq"
      }).then((response) => {
        configure.yyaqList = response.data;
      });
      setTimeout(() => {
        sessionStorage.setItem('configure',JSON.stringify(configure));
      }, 1000)
    },
  }
}
</script>
<style>

  #app{
        overflow: auto;

  }
  /* ::-webkit-scrollbar{
    width:0;
     height:8px;
     background: rgb(200,200,200);
     border-radius: 6px;
   }
    ::-webkit-scrollbar-thumb{
     background: rgb(0,121,188);
     border-radius: 6px;
   } */
  .el-dialog__wrapper{
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .el-dialog:not(.is-fullscreen){
    margin-top: 0 !important;

  }
  .el-dialog__body{
     padding: 10px 30px!important;
  }
 .el-input-group__prepend,.el-input-group__append{
      height: 26px !important;
      line-height: 26px !important;
      background-color: white !important;
      /* color: #ccc !important; */
      width: 40px !important;
      padding-left: 0 !important;
      padding-right: 0 !important;
      text-align: center !important;
  }

</style>
